package com.javabasic.interview_4399;

/**
 * @Author xiongmin
 * @Description TODO
 * @Date 2019/10/11 19:23
 * @Version 1.0
 **/
public class OneProblem {

    public static void main(String[] args) {
        int[] arr = new int[]{10,9, 8, 8,7, 7, 5,3,1};
        System.out.println(bin_find(arr, arr.length, 8));
    }

    public static int bin_find(int arr[],int arr_size, int num) {
        int left = 0, right = arr_size-1;
        while (left < right-1) {
            int mid = left + (right-left)/2;
            if(arr[mid] > num) {
                left = mid;
            } else {
                right = mid-1;
            }
        }
        return right;
    }
}
